package com.melody.android.logic.database.repository;

import com.melody.android.logic.database.dao.SongListDao;
import com.melody.android.logic.model.SongList;

import java.util.List;

public class SongListRepositoryImpl implements SongListRepository {

    private final SongListDao songListDao;

    public SongListRepositoryImpl(SongListDao songListDao) {
        this.songListDao = songListDao;
    }

    /**
     * 新增自定义歌单
     * @param songList SongList实例对象
     */
    @Override
    public void addSongList(SongList songList) {
        songListDao.insertSongList(songList);
    }

    /**
     * 移除自定义歌单
     * @param songList SongList实例对象
     */
    @Override
    public void removeSongList(SongList songList) {
        int SLid = songListDao.getSLidBySongListName(songList);
        if (SLid != -1) {
            songListDao.deleteSongList(SLid);
        }
    }

    /**
     * 获取全部自定义歌单
     * @return 全部自定义歌单
     */
    @Override
    public List<SongList> getAllSongLists() {
        return songListDao.getAllSongLists();
    }

}
